package com.sgb.trip.viewmodel;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;

import com.sgb.trip.api.TripNet;
import com.sgb.trip.entity.FlightOrderDetailEntity;
import com.swgk.core.base.api.ICallBack;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.common.base.BaseViewModel;
import com.swgk.core.dialog.DialogHelper;

/**
 * Time:2021/9/13
 * Author:黄淋
 * Description:
 */
public class FlightOrderDetailSelfModel extends BaseViewModel {
    public MutableLiveData<FlightOrderDetailEntity> ldOrdersData = new MutableLiveData<>();

    public FlightOrderDetailSelfModel(@NonNull Application application) {
        super(application);
    }

    /**
     * 加载机票订单详情
     */
    public void getFligtOrderDetail(String orderNo) {

        TripNet.getInstance().getService().getFligtOrderDetail(orderNo).enqueue(new ICallBack<BaseEntity<FlightOrderDetailEntity>>() {
            @Override
            public void onSuccess(BaseEntity<FlightOrderDetailEntity> data) {
                DialogHelper.dismissProgressDialog();
                if (data == null || data.getState() == null || data.getData() == null) {
                    return;
                }

                if (data.getData() != null) {
                    ldOrdersData.postValue(data.getData());
                }
            }

            @Override
            public void onFailureWithEntity(BaseEntity entity) {
                DialogHelper.dismissProgressDialog();
            }
        });


    }

}
